<!-- 所有者信息  ---》来自登录信息 -->

<!-- ———————————————————————————————————— 诊所信息 ———————————————————————————————————— -->
<template>
  <div id="box">
    <div id="message">
      <!-- 头部左边 -->
      <div class="left">
        <h2>所有者信息<span>（诊所最高负责人为所有者）</span></h2>
        <span id="OwnerName">所有者姓名：</span
        ><el-input
          v-model="loginUser"
          class="name"
          placeholder="请输入你的名字"
          clearable
        />
        <br />
        <span id="job">职务：</span
        ><el-input
          v-model="loginJob"
          class="post"
          placeholder="请输入职务"
          clearable
        />
      </div>

      <!-- 头部右边 -->
      <div class="right">
        <el-button
          type="primary"
          class="update"
          v-if="updataVisible"
          @click="update"
          >修改</el-button
        >
        <el-button type="primary" v-if="sureVisible" class="sure" @click="sure"
          >保存</el-button
        >
      </div>
    </div>

    <!-- 详细内容展示 -->
    <div class="section">
      <!-- 内容展示左边 -->
      <div class="left2">
        <h2>诊所信息<span>（关于诊所的基本信息及最大成员数量）</span></h2>

        <!-- 诊所名称 -->
        <span id="ClinicName">诊所名称：</span
        ><el-input
          v-model="ClinicName"
          class="Name"
          placeholder="请输入诊所名称"
          clearable
        />
        <br />

        <!-- 医生数量 -->
        <span id="doctorNum">医生数量：</span
        ><el-input
          v-model="doctorNum"
          class="num"
          placeholder="请输入医生数量"
          clearable
        />
        <br />

        <!-- 诊所科室 -->
        <span id="ClinicDepartment">诊所科室：</span
        ><el-input
          v-model="ClinicDepartment"
          class="department"
          placeholder="请输入诊所科室"
          clearable
        />

        <br />

        <!-- 专业方向 -->
        <span id="majorField">专业方向：</span
        ><el-input
          v-model="majorField"
          class="field"
          placeholder="请输入专业方向"
          clearable
        />
        <br />

        <!-- 诊所地址 -->
        <span id="ClinicAddress">诊所地址：</span
        ><el-input
          v-model="ClinicAddress"
          class="address"
          placeholder="请输入诊所地址"
          clearable
        />
        <br />

        <!-- 诊所简介 -->
        <span id="textarea">诊所简介：</span>
        <br />
        <el-input
          v-model="textarea"
          :rows="2"
          class="text"
          type="textarea"
          placeholder="全科医院 万家医疗合作单位 。"
        />
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import axios from "@/utils/http";
import { onBeforeMount, onMounted, ref } from "vue";
import { useStore } from "vuex";
const name = ref("");
const input = ref("");
const ClinicName = ref("");
const doctorNum = ref("");
const ClinicDepartment = ref("");
const majorField = ref("");
const ClinicAddress = ref("");
const textarea = ref("");

/* —————————————————————— 获取所有者信息 —————————————————————— */
onMounted(() => {
  console.log("发请求获取所有者信息");
  //发请求
});

const store = useStore();
let loginUser = ref(""); //登录者名字
let loginJob = ref(""); //登录者职务
/* —————————————————————————————————————— 获取用户信息 ——————————————————————————————————————*/
onBeforeMount(() => {
  //获取用户信息

  //获取到登录者名字  --》vuex里面的死数据
  let user = store.state.router.userData.userInfo.empUserName;
  loginUser = user;

  //获取到登录者职务  --》vuex里面的死数据
  let job = store.state.router.userData.userInfo.empGrade;
  loginJob = job;

  console.log(axios);

  //发请求
  axios({
    url: "/setting/systemHospitalinformation/fundHospitalinformation",
    method: "get",
  })
    .then((res) => {
      //获取到的数据
      console.log(res);
      //获取成功后，拿到后台对应的数据
      ClinicName.value = res.data.data.hospitalinName;
      majorField.value = res.data.data.hospitalinPfnd;
      ClinicAddress.value = res.data.data.hospitalinAddress;
      textarea.value = res.data.data.hospitalinProfile;
    })
    .catch((err) => {
      console.log(err);
    });
});

/* —————————————————————————————————————— 诊所信息 —————————————————————————————————————— */
onMounted(() => {
  axios({
    url: "/setting/systemHospitalinformation/fundAdministratives",
    method: "get",
  })
    .then((res) => {
      console.log(res);
      //获取成功后，拿到后台对应的数据
      doctorNum.value = res.data.data.department;
      ClinicDepartment.value = res.data.data.number;
    })
    .catch((err) => {
      console.log(err);
    });
});
/* —————————————————————————————————————— 获取诊所信息 ——————————————————————————————————————*/
let sureVisible = ref(false);
let updataVisible = ref(true);

//点击修改
let update = () => {
  console.log("点击了修改");
  sureVisible.value = true;
  updataVisible.value = false;
};

//点击保存
let sure = () => {
  console.log("点击了保存");
  sureVisible.value = false;
  updataVisible.value = true;
  //拿到修改的值
  //获取到修改的值
  let value1 = majorField.value;
  let value2 = ClinicAddress.value;
  let value3 = textarea.value;
  let value4 = ClinicName.value;
  console.log(value1, value2, value3,value4);
  console.log('--------------------');
  console.log(axios);
  
  
  //发起请求
  axios({
    url: "/setting/systemHospitalinformation/addHospitalinformation",
    method: "post",
    data: {
      hospitalinAddress:value2,
      hospitalinName:value4 ,
      hospitalinPfnd:value1 ,
      hospitalinProfile:value3,
    },
  })
    .then((res) => {
      console.log(res);
    })
    .catch((err) => {
      console.log(err);
    });
};
</script>

<style scoped>
#box {
  width: 100%;
  height: 800px;
  background: #f3f5f8;
  position: relative;
}
#message {
  width: 100%;
  height: 160px;
  background: white;
  /* border: 1px solid blue; */
  position: absolute;
  top: 35px;
  border: 1px solid rgb(247, 244, 244);
  box-shadow: 1px 2px rgb(233, 230, 230);
}
/* 左边 */
.left {
  float: left;
  width: 50%;
  height: 150px;
  background: white;
}

.left > h2 {
  font-weight: 500;
  color: #429bff;
}

.left > h2 > span {
  font-weight: 200;
  font-size: 16px;
  color: black;
}
.name,
.post {
  width: 400px;
}

.el-input {
  --el-input-text-color: black;
  --el-input-border: none;
  --el-input-hover-border: none;
  --el-input-border-color: none;
  --el-input-placeholder-color: black;
  --el-input-hover-border-color: none;
  --el-input-focus-border-color: none;
}

#OwnerName,
#job {
  display: inline-block;
  width: 100px;
  /*  ; */
  height: 30px;
  line-height: 30px;
}

#job {
  margin: 20px 0;
}

/* 右边 */
.right {
  float: right;
  height: 50px;
  width: 50%;
  /* background: skyblue; */
  text-align: right;
  position: relative;
  height: 150px;
}

.update,
.sure {
  position: absolute;
  top: 10px;
  width: 120px;
  height: 40px;
  font-size: 18px;
  right: 20px;
}

/* 详细内容展示 */
.section {
  width: 100%;
  height: 420px;
  background: white;
  /* border: 1px solid blue; */
  position: absolute;
  top: 225px;
  border: 1px solid rgb(247, 244, 244);
  box-shadow: 1px 1px rgb(245, 243, 243);
}

/* 详细内容展示 */
/* 左边 */
.left2 {
  float: left;
  width: 100%;
  height: 420px;
  background: white;
}

.left2 > h2 {
  font-weight: 500;
  color: #429bff;
}

.left2 > h2 > span {
  font-weight: 200;
  font-size: 16px;
  color: black;
}
.Name,
.num,
.department,
.field,
.address,
.text {
  width: 800px;
  margin: 10px 0;
}

.text {
  margin: 10px 40px;
}

.el-input,
.el-textarea {
  --el-input-text-color: black;
  --el-input-border: none;
  --el-input-hover-border: none;
  --el-input-border-color: none;
  --el-input-placeholder-color: black;
  --el-input-hover-border-color: none;
  --el-input-focus-border-color: none;
}
</style>>
